package com.cf.service.impl;

import com.cf.dao.RewardDao;
import com.cf.entity.Reward;
import com.cf.service.RewardService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class RewardServiceImpl implements RewardService {
    @Autowired
    private RewardDao rewardDao;

    @Override
    public PageInfo<Reward> selectReward(int pageNum , int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Reward> rewards = rewardDao.selectReward();
        PageInfo<Reward> pageInfo = new PageInfo<>(rewards);
        return pageInfo;
    }

    @Override
    public int deleteReward(long rewardid) {
        return rewardDao.deleteReward(rewardid);
    }

    @Override
    public int updateReward(Reward reward) {
        return rewardDao.updateReward(reward);
    }

    @Override
    public int insertReward(Reward reward) {
        return rewardDao.insertReward(reward);
    }

    @Override
    public PageInfo<Reward> selectByItemid(long iid, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Reward> rewards = rewardDao.selectByItemid(iid);
        PageInfo<Reward> pageInfo = new PageInfo<>(rewards);
        return pageInfo;
    }

    @Override
    public Reward selectByrewardid(long rewardid) {
        return rewardDao.selectByrewardid(rewardid);
    }

    @Override
    public int selectBymoney(long iid,long paymoney) {
        return rewardDao.selectBymoney(iid,paymoney);
    }

    @Override
    public int deleteByIid(long iid) {
        return rewardDao.deleteByIid(iid);
    }
}
